
package assdraw.event;

import assdraw.model.Drawing;
import assdraw.model.Shape;
import assdraw.model.ShapeGroup;


public class DrawingEvent
{

	public static final int SHAPE_ADDED = 0;
	public static final int SHAPE_MOVED = 1;
	public static final int SHAPE_SELECTION = 2;
	public static final int SHAPE_DELETED = 3;
	public static final int SHAPE_GROUP = 4;
	public static final int SHAPE_UNGROUP = 5;
	public static final int RESIZE = 6;
	
    private Drawing source;
    private int kind;
    private Shape shape;
    
    public DrawingEvent(Drawing source, int eventKind, Shape s)
    {
        this.source = source;
        this.kind = eventKind;
        this.shape = s;
    }
    

	public Drawing getSource()
    {
        return source;
    }
    
    public int getKind()
    {
        return kind;
    }

	public String getText() {
		switch(kind){
			case SHAPE_ADDED:
				return "Shape " + shape.toString() + " added at " + shape.getX()+","+shape.getY()+".";
			case SHAPE_DELETED:				
				return  "Shape(s) deleted.";
			case SHAPE_GROUP:
				if(shape instanceof ShapeGroup){
					return ((ShapeGroup)shape).getComponents().size() +" shapes grouped.";
				}
				return "Shapes grouped.";
			case SHAPE_MOVED:
				return "Shape "+ shape.toString()+ " Z order changed.";
			case SHAPE_SELECTION:
				return "Shape "+ shape.toString()+" added to selection.";
			case SHAPE_UNGROUP:				
				//return "Shape group with "+ ((ShapeGroup)shape).getComponents().size()+" ungrouped.";
				return "Selected shapes ungrouped.";
		}
		return null;
	}


	public Shape getShape() {
		return shape;
	}

}
